package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.BusSleepRecordMapper;
import com.ruoyi.system.domain.BusSleepRecord;
import com.ruoyi.system.service.IBusSleepRecordService;
import com.ruoyi.common.core.text.Convert;

/**
 * 睡眠记录Service业务层处理
 *
 * @author wuxiao
 * @date 2025-09-28
 */
@Service
public class BusSleepRecordServiceImpl implements IBusSleepRecordService
{
    @Autowired
    private BusSleepRecordMapper busSleepRecordMapper;

    /**
     * 查询睡眠记录
     *
     * @param id 睡眠记录主键
     * @return 睡眠记录
     */
    @Override
    public BusSleepRecord selectBusSleepRecordById(Integer id)
    {
        return busSleepRecordMapper.selectBusSleepRecordById(id);
    }

    /**
     * 查询睡眠记录列表
     *
     * @param busSleepRecord 睡眠记录
     * @return 睡眠记录
     */
    @Override
    public List<BusSleepRecord> selectBusSleepRecordList(BusSleepRecord busSleepRecord)
    {
        return busSleepRecordMapper.selectBusSleepRecordList(busSleepRecord);
    }

    /**
     * 新增睡眠记录
     *
     * @param busSleepRecord 睡眠记录
     * @return 结果
     */
    @Override
    public int insertBusSleepRecord(BusSleepRecord busSleepRecord)
    {
        Long userId = ShiroUtils.getUserId();
        busSleepRecord.setUserId(userId);
        busSleepRecord.setCreateTime(DateUtils.getNowDate());
        return busSleepRecordMapper.insertBusSleepRecord(busSleepRecord);
    }

    /**
     * 修改睡眠记录
     *
     * @param busSleepRecord 睡眠记录
     * @return 结果
     */
    @Override
    public int updateBusSleepRecord(BusSleepRecord busSleepRecord)
    {
        busSleepRecord.setUpdateTime(DateUtils.getNowDate());
        return busSleepRecordMapper.updateBusSleepRecord(busSleepRecord);
    }

    /**
     * 批量删除睡眠记录
     *
     * @param ids 需要删除的睡眠记录主键
     * @return 结果
     */
    @Override
    public int deleteBusSleepRecordByIds(String ids)
    {
        return busSleepRecordMapper.deleteBusSleepRecordByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除睡眠记录信息
     *
     * @param id 睡眠记录主键
     * @return 结果
     */
    @Override
    public int deleteBusSleepRecordById(Integer id)
    {
        return busSleepRecordMapper.deleteBusSleepRecordById(id);
    }
}
